#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CombatManager.generated.h"

struct FInputActionValue;
class UInputAction;

UCLASS()
class ANIMSAMPLE_API ACombatManager: public AActor
{
	GENERATED_BODY()

public:
	ACombatManager();

	virtual void Tick(float DeltaTime) override;
	
	UFUNCTION(BlueprintCallable)
	static ACombatManager* Get();
	
	UFUNCTION(BlueprintCallable)
	const UDataTable* GetCombatSchemesDataTable();
	
protected:
	virtual void BeginPlay() override;
	
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
	UDataTable* CombatSchemesDataTable = nullptr;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input)
	UInputAction* IA_AttackLight;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input)
	UInputAction* IA_AttackHeavy;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input)
	UInputAction* IA_Defense;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input)
	UInputAction* IA_Parry;
	
private:
	static ACombatManager* CombatManagerInstance;
	
	void ProcessInputActionBinding();
	void OnAttackLightTriggered(const FInputActionValue& Value);
	void OnAttackHeavyTriggered(const FInputActionValue& Value);
	void OnDefenseTriggered(const FInputActionValue& Value);
	void OnParryTriggered(const FInputActionValue& Value);
};
